<!DOCTYPE html>
<html>
<head>
<title>页面视口的大小</title>
</head> 
<body>
    <script>
        var pageWidth = window.innerWidth,
            pageHeight = window.innerHeight;
        if (typeof pageWidth != "number") {
            if (document.compatMode == "CSS1Compat") {
                pageWidth = document.documentElement.clientWidth;
                pageHeight = document.documentElement.clientHeight;
            } else {
                pageWidth = document.body.clientWidth;
                pageHeight = document.body.clientHeight;
            }
        }
    </script>
    </body>

</html>